Skip to content

Remove trace_names reassignment that results in reallocation and potential segfault - #130

Open
dfnca wants to merge 1 commit into
nasa:mainfrom
dfnca:fix/legacyRktTraceSegFault
Open

Remove trace_names reassignment that results in reallocation and potential segfault#130
dfnca wants to merge 1 commit into
nasa:mainfrom
dfnca:fix/legacyRktTraceSegFault

Conversation

@dfnca

@dfnca dfnca commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes #129 by removing an assignment statement that results in reallocation of memory that can cause subsequent attempt to access out-of-bounds during output using the legacy interface.

Changes

Remove the following lines in two places, main.f90 / rocket_output:
trace_names = trace_names(:num_trace)

This statement reallocates trace_names to length num_trace. If subsequent solutions had more than num_trace trace species, a memory error / segfault will occur.

Testing

  1. Example input file that originally generated a segfault now runs correctly. The output matches expected results that were generated by reordering the solutions to avoid the bug.
  2. 100% pass on ctest, legacy interface test, and pytest. Note: pytest generates a bunch of warnings, but the same warnings are generated when running the HEAD code, which does not include this fix.
    bugExample.inp.txt
    bugExample.out.txt
    runsOK.inp.txt
    runsOK.out.txt

Compatibility / Numerical behavior

  • [ X] No expected changes to numerical results
  • Expected changes (explain and provide validation)

…ally decreasing the array size such that subsequent outputs go out-of-bounds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] segfault in rocket problem using legacy interface

1 participant